package com.huangjue.backend.service.impl;

import com.huangjue.backend.entity.StudentCourse;
import com.huangjue.backend.mapper.StudentCourseMapper;
import com.huangjue.backend.service.StudentCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentCourseServiceImpl implements StudentCourseService {
    @Autowired
    private StudentCourseMapper studentCourseMapper;

    @Override
    public StudentCourse getByUserIdAndCourseId(Integer userId, Integer courseId) {
        return studentCourseMapper.selectByUserIdAndCourseId(userId, courseId);
    }

    @Override
    public int save(StudentCourse studentCourse) {
        return studentCourseMapper.insert(studentCourse);
    }

    @Override
    public int update(StudentCourse studentCourse) {
        return studentCourseMapper.update(studentCourse);
    }

    @Override
    public boolean isChooseCourse(Integer userId, Integer courseId) {
        return studentCourseMapper.isChooseCourse(userId, courseId) > 0;
    }

    @Override
    public boolean chooseCourse(Integer userId, Integer courseId) {
        return studentCourseMapper.chooseCourse(userId, courseId) > 0;

    }
} 